import requests, json

def get_image(harbor_url, repo_name, project_name, username, password):
    url = f"{harbor_url}/api/repositories/{repo_name}/{project_name}/tags?detail=1"
    response = requests.get(url, auth=(username, password))
    return response

# http://192.168.235.134:60195/api/repositories/demo/zookeeper/tags/3.9.5

def delete_image(harbor_url, repo_name, project_name, image_version, username, password):
    url = f"{harbor_url}/api/repositories/{repo_name}/{project_name}/tags/{image_version}"
    response = requests.delete(url, auth=(username, password))
    return response

#  http://192.168.235.134:60195/api/repositories/demo/zookeeper/tags?detail=1
# http://192.168.235.134:60195/api/repositories/demo/zookeeper/tags/3.9.5

# harbor_url = "http://harbor.irissz.com:60195"
# repo_name = "scmv6"
# project_name = "center-batch"
# username = "admin"
# password = "iris@Harbor2020"

harbor_url = "http://192.168.235.134:60195"
repo_name = "demo"
project_name = "center-merge"
image_version = "504ee4b"
username = "admin"
password = "iris@Harbor2020"

# 假设你有一个镜像摘要列表
digests = ["digest1", "digest2", "digest3"]

# for digest in digests:
# res1 = get_image(harbor_url, repo_name, project_name, username, password)
# print(res1.text)

# image_name = "fc9e35f"
#
res2 = delete_image(harbor_url, repo_name, project_name, image_version, username, password)
print(res2)

